<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
            <el-form-item label="LOG表ID" prop="logId">
                <el-input v-model="queryParams.logId" placeholder="LOG表ID"></el-input>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button type="warning" plain icon="el-icon-download" @click="handleExport">导出</el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :search="false"></right-toolbar>
        </el-row>
        <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange" :height="tableHeight - 19"
            border>
            <!-- <el-table-column type="selection" width="55" align="center" /> -->
            <el-table-column label="目标文件格式" align="center" prop="transType" :show-overflow-tooltip="true" />
            <el-table-column label="目标文件路径" align="center" prop="transUrl" :show-overflow-tooltip="true" />
            <el-table-column label="源文件格式" align="center" prop="docName" :show-overflow-tooltip="true" />
            <el-table-column label="是否成功" align="center" prop="state" :show-overflow-tooltip="true" >
                <template slot-scope="scope">
                    {{scope.row.state==0?"失败":"成功"}}
                </template>
            </el-table-column>
            <!-- <el-table-column label="日志信息" align="center" prop="logMsg" :show-overflow-tooltip="true" /> -->
            <el-table-column label="LOG表ID" align="center" prop="logId" :show-overflow-tooltip="true" />
            <el-table-column label="源文件路径" align="center" prop="originalUrl" :show-overflow-tooltip="true" />
            <el-table-column label="操作" align="center" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    <el-button type="danger" size="small" @click="handleDelete(scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" />

    </div>
</template>
  
<script>

import { logDatailsList, logDatailsdel } from "@/api/formatConversion/formatGSXHList.js"
import estimateTableHeight from '@/mixins/estimateTableHeight';
import vDeit from "@/views/formatConversion/formatConversion/deit.vue"
import { delFONDS } from "@/api/manage/general";
export default {
    components: {
        vDeit
    },
    mixins: [estimateTableHeight], // 混入方法
    name: "Dict",
    data() {
        return {
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 表格数据
            list: [],
            // 弹出层标题
            title: "",

            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                briefInfo: undefined,
                convertTime: undefined,
            },
        };
    },
    created() {
        this.getList();
    },
    methods: {
        table_index(index) {
            return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1;
        },
        /** 查询字典类型列表 */
        getList() {
            this.loading = true;
            logDatailsList(this.queryParams).then(response => {
                this.list = response.rows;
                console.log(this.list,"======================")
                this.total = response.total;
                this.loading = false;
            }
            );
        },

        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.id)
            this.single = selection.length != 1
            this.multiple = !selection.length
        },



        /** 导出按钮操作 */
        handleExport() {
            // if(!this.multiple){
            this.download('/cqbc/gszh/logDatails/export', {
                ...this.queryParams
            }, `type_${new Date().getTime()}.xlsx`)
            // }else{
            //     this.$message({ message: '请选择要导出的数据!', type: 'warning' })
            // }
        },


        //删除
        handleDelete(row) {
            this.$modal.confirm('是否确认删除所选数据项？').then(function () {
                return logDatailsdel(row.docId);
            }).then(() => {
                this.getList();
                this.$modal.msgSuccess("删除成功");
            }).catch(() => { });
        },
        //搜索
        handleQuery() {
            this.queryParams.pageNum = 1
            this.getList();
        },

        //重置
        resetQuery() {
            this.$refs.queryForm.resetFields();
            this.resetForm('queryForm')
            this.queryParams = {
                pageNum: 1,
                pageSize: 10,
                briefInfo: undefined,
                convertTime: undefined,
            }
            this.getList();
        }
    }
};
</script>
  